﻿#region COPYRIGHT
//--------------------------------------------------------------------------------
// <copyright file="Margin.cs" company="starLiGHT Entertainment Studios">
//    Copyright (c) 2011 
//       Roland Rosenkranz (Glatzemann@email.de)
// </copyright>
// <license>
//   This file is part of starLiGHT.GUI.
//
//   It is released under the Microsoft Public License (Ms-PL).
//
//   You should have received a copy of the Microsoft Public License
//   along with starLiGHT.GUI. If not, see http://sle.codeplex.com/license.
//    
//   ADDITIONAL (commercial) LICENSES for starLiGHT.GUI are available on request.
// </license>
// <version>
// **************[ starLiGHT.Engine SVN ]**********************
// * $Rev::                       $:  Revision of last commit *
// * $Author::                    $:  Author of last commit   *
// * $Date::                      $:  Date of last commit     *
// ************************************************************
// </version>
//--------------------------------------------------------------------------------
#endregion

namespace starLiGHT.GUI
{
#region Using Statements
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
#endregion

    public class Margin : SkinElement
    {
        #region Private Members
        private static int nextId = 0;
        private float left;
        private float right;
        private float top;
        private float bottom;
        #endregion

        public Margin(string typeName)
            : base(typeName + (nextId++).ToString())
        {
        }

        public bool IsEmpty
        {
            get
            {
                return this.left == 0f && this.right == 0f && this.top == 0f && this.bottom == 0f;
            }
        }

        public float Left
        {
            get
            {
                return this.left;
            }

            set
            {
                this.left = value;
            }
        }

        public float Right
        {
            get
            {
                return this.right;
            }

            set
            {
                this.right = value;
            }
        }

        public float Top
        {
            get
            {
                return this.top;
            }

            set
            {
                this.top = value;
            }
        }

        public float Bottom
        {
            get
            {
                return this.bottom;
            }

            set
            {
                this.bottom = value;
            }
        }

        public RectangleF Apply(RectangleF source)
        {
            return new RectangleF(
                source.X        + this.left,
                source.Y        + this.top,
                source.Width    + this.right - this.left,
                source.Height   + this.bottom - this.top);
        }
    }
}
